<?php

/**
 * MlIncidents filter form base class.
 *
 * @package    maslogger
 * @subpackage filter
 * @author     Michaël VEROUX
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseMlIncidentsFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'machine_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('MlMachines'), 'add_empty' => true)),
      'version_id'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'intervention'      => new sfWidgetFormFilterInput(),
      'solution'          => new sfWidgetFormFilterInput(),
      'photo'             => new sfWidgetFormFilterInput(),
      'pieces_remplaces'  => new sfWidgetFormFilterInput(),
      'controler'         => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'sfm'               => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'controler_do'      => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'sfm_do'            => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'priorite'          => new sfWidgetFormChoice(array('choices' => array('' => '', 'A faire' => 'A faire', 'Fait' => 'Fait'))),
      'presence_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
      'intervention_date' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'created_by'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Creator'), 'add_empty' => true)),
      'updated_by'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Updator'), 'add_empty' => true)),
      'created_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'version'           => new sfWidgetFormFilterInput(),
      'deleted_at'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'machine_id'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('MlMachines'), 'column' => 'id')),
      'version_id'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'intervention'      => new sfValidatorPass(array('required' => false)),
      'solution'          => new sfValidatorPass(array('required' => false)),
      'photo'             => new sfValidatorPass(array('required' => false)),
      'pieces_remplaces'  => new sfValidatorPass(array('required' => false)),
      'controler'         => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'sfm'               => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'controler_do'      => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'sfm_do'            => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'priorite'          => new sfValidatorChoice(array('required' => false, 'choices' => array('A faire' => 'A faire', 'Fait' => 'Fait'))),
      'presence_id'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('sfGuardUser'), 'column' => 'id')),
      'intervention_date' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'created_by'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Creator'), 'column' => 'id')),
      'updated_by'        => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Updator'), 'column' => 'id')),
      'created_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'version'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'deleted_at'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('ml_incidents_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'MlIncidents';
  }

  public function getFields()
  {
    return array(
      'id'                => 'Number',
      'machine_id'        => 'ForeignKey',
      'version_id'        => 'Number',
      'intervention'      => 'Text',
      'solution'          => 'Text',
      'photo'             => 'Text',
      'pieces_remplaces'  => 'Text',
      'controler'         => 'Boolean',
      'sfm'               => 'Boolean',
      'controler_do'      => 'Boolean',
      'sfm_do'            => 'Boolean',
      'priorite'          => 'Enum',
      'presence_id'       => 'ForeignKey',
      'intervention_date' => 'Date',
      'created_by'        => 'ForeignKey',
      'updated_by'        => 'ForeignKey',
      'created_at'        => 'Date',
      'updated_at'        => 'Date',
      'version'           => 'Number',
      'deleted_at'        => 'Date',
    );
  }
}
